/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2010.

	This file is part of Maxsi Distribution.

	Maxsi Distribution is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi Distribution is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
	or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
	License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Distribution. If not, see <http://www.gnu.org/licenses/>.

	Maxsi Distribution
	A powerful digital distribution library designed for games and software.

	MaxsiDistributionRelease001.cpp
	A system that allows you to release product data to master servers and
	several content servers.

******************************************************************************/

#include "MaxsiLibrary.h"
#include "MaxsiDistribution.h"

//=============================================================================
//	Before we start, reset all the interface version information.
//=============================================================================
#ifdef MaxsiDistributionRelease
#undef MaxsiDistributionRelease
#endif
#ifdef MaxsiDistributionRelease_String
#undef MaxsiDistributionRelease_String
#endif	
#ifdef MaxsiDistributionReleaseCallback
#undef MaxsiDistributionReleaseCallback
#endif

#define MD_IRelease MD_IRelease001
#define MD_IRelease_String "MD_IRelease001"

//=============================================================================
//	Alrighty, now let's get cracking!
//=============================================================================
MAXSI_DEFINE_SELF_IMPLEMENTATION(MD_IRelease, MAXSI_INTERFACE_STATIC);

MaxsiHandle MD_IRelease::Release(MD_ReleaseCallback Callback, BYTE* UserData, MESTR* ContentArchive, MESTR** MasterServers, size_t NumMasterServers, MESTR** ContentServers, size_t NumContentServers, MESTR* MasterImagePath)
{
	MD_Release*		Result		=	new MD_Release;

	Result->Callback			=	Callback;
	Result->UserData			=	UserData;
	Result->NumMasterServers	=	NumMasterServers;
	Result->NumContentServers	=	NumContentServers;

	Result->ContentArchive		=	BuildString(1, ContentArchive);
	Result->MasterServers		=	DuplicateStringList(MasterServers, NumMasterServers);
	Result->ContentServers		=	DuplicateStringList(ContentServers, NumContentServers);
	Result->MasterImagePath		=	BuildString(1, MasterImagePath);
	
	Result->Caller				=	this;

	MaxsiError ReleaseResult = Result->Release();

	if ( ReleaseResult != MAXSI_ERROR_SUCCESS ) { SetError(ReleaseResult); delete Result; return NULL; }

	return (MaxsiHandle)Result;	
}


